
public class ArrayQueue <E>{

	private int tail;

	@SuppressWarnings("unchecked")
	private E[] queue = (E[]) new Object[10];
	
	public ArrayQueue(){
		this.tail = -1;
	}
	
	public boolean offer(E item){
		if(this.tail == 9 || item == null){
			return false;
		}
		
		for(int i = 0; i <= tail; i++){
			if(queue[i].equals(item)){
				return false;
			}
		}

		tail++;
		queue[tail] = item;
		return true;
	}
	
	/**
	 * Redoes the whole array each time.
	 * 
	 * @return
	 */
	public E poll(){
		if(tail == -1){
			System.out.println("The queue is empty");
			return null;
		}
		tail--;
		E temp = queue[0];
		for(int i = 0; i < 9; i++){
			queue[i] = queue[i + 1];
		}
		
		return temp;
	}
}
